package com.hiv.controller.wechat;

import com.hiv.common.BaseController;
import com.hiv.common.WebResponse;
import com.hiv.common.param.StatisticsParam;
import com.hiv.common.response.DoctorStatisticsInfo;
import com.hiv.common.response.SamplerStatisticsInfo;
import com.hiv.mapper.domain.Admin;
import com.hiv.service.StatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author zhanghong
 * @version XcxStatisticsController.java, v 0.1 2022-09-20 XcxStatisticsController Exp $$
 */
@RestController
@RequestMapping("/wechat/statistics")
@Api(value = "统计模块", tags = {"【小程序端】统计模块"})
public class XcxStatisticsController extends BaseController {
    @Autowired
    private StatisticsService statisticsService;

    @ApiOperation(value = "采样员统计信息", httpMethod = "POST")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "success")})
    @PostMapping("/sampler")
    public WebResponse<SamplerStatisticsInfo> samplerStatistics(HttpServletRequest request, @RequestBody StatisticsParam param) {
        Admin samplingUser = validUserLoginAndGet(request, Admin.class);
        return WebResponse.build(statisticsService.samplerStatistics(samplingUser, param));
    }

    @ApiOperation(value = "医生统计信息", httpMethod = "POST")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "success")})
    @PostMapping("/docker")
    public WebResponse<DoctorStatisticsInfo> dockerStatistics(HttpServletRequest request, @RequestBody StatisticsParam param) {
        Admin dockerUser = validUserLoginAndGet(request, Admin.class);
        return WebResponse.build(statisticsService.dockerStatistics(dockerUser, param));
    }
}
